package cn.vcjf.washcar.mpGenerator;

import cn.vcjf.washcar.common.util.QiniuUploadFile;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

/**
 * @Auther: zhengzihang
 * @Date: 2018/7/18 17:31
 * @Description:
 */
public class CarBrand {


	public static void main2(String[] args) throws Exception {

		FileReader reader=new FileReader("D://Downloads/cars.json");
		BufferedReader bf=new BufferedReader(reader);
		StringBuffer buffer = new StringBuffer(614400);
		String s = null;
		while ((s = bf.readLine())!=null){
			buffer.append(s);
		}
		JSONObject object = JSON.parseObject(buffer.toString());
		Set<Map.Entry<String, Object>> entries = object.entrySet();

		for(Map.Entry<String, Object> entry: entries){
			System.out.println("---"+entry.getKey());
			Object value = entry.getValue();
			List<Map<String,String>> list = (List<Map<String,String>>) value;
			for(Map<String,String> m:list){
				String name = m.get("name");
				String img = m.get("img");
				//  data:image/png;base64,
				System.out.println("name="+name+"\t,img="+img);
				String s1 = QiniuUploadFile.put64(img);

				return;
			}

		}
	}

	public static void main(String[] args) throws IOException {
		String property = System.getProperty("user.dir");
		Properties properties=new Properties();
//		InputStream is=new FileInputStream(new File("D:\\bc-project/language.txt"));
//		System.out.println(System.getProperty("user.dir"));
		FileReader reader = new FileReader(new File("D:\\bc-project/language.txt"));
		properties.load(reader);

		Set<String> strings = properties.stringPropertyNames();
		for (String key : strings) {
			System.out.println("key="+key+",value="+properties.getProperty(key));
//			System.out.println(key);
//			System.out.println(properties.getProperty(key));
		}
//		String path = CarBrand.class.getResource("/").getPath();
//		System.out.println(path);
	}
}
